/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package EventHandler;

import app.bus.ProductModel;
import app.entities.Product;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mvc.Event;

/**
 *
 * @author Tuan Long
 */
public class ProductDetail implements Event{

    @Override
    public String EventHandler(HttpServletRequest request, HttpServletResponse response) {
        String productID = request.getParameter("ProductID");
        if(productID!=null){
            Product p = ProductModel.getProductByID(productID);
            if(p!=null){
                request.setAttribute("pd", p);
            }
            int count = ProductModel.getTotalProductRows();
            request.setAttribute("count", count);
        }
        
        return "ProductDetail.jsp";
    }
    
}
